﻿import re

from google.appengine.ext import db

class Song(db.Model):
    #id = db.IntegerProperty()
    
    title = db.StringProperty()
    
    artist = db.StringProperty()
    
    singer = db.StringProperty()
    lyricist = db.StringProperty()
    composer = db.StringProperty()
    
    track = db.IntegerProperty()
    
    album_name = db.StringProperty()
    pub_time = db.DateTimeProperty()
    
    genres = db.StringProperty()
    description = db.TextProperty()
    
    length = db.IntegerProperty() #in seconds
    
    created_by = db.UserProperty()
    
    created_at = db.DateTimeProperty(auto_now_add = True)
    updated_at = db.DateTimeProperty(auto_now = True)

class Cover(db.Model):
    song = db.ReferenceProperty(Song)
    user = db.StringProperty()
    
    img_data = db.BlobProperty()
    created_at = db.DateTimeProperty(auto_now_add = True)
    updated_at = db.DateTimeProperty(auto_now = True)

class SongBlob(db.Model):
    song = db.ReferenceProperty(Song)
    user = db.StringProperty()
    
    song_data = db.BlobProperty()
    created_at = db.DateTimeProperty(auto_now_add = True)
    updated_at = db.DateTimeProperty(auto_now = True)

class SongResource(db.Model):
    song = db.ReferenceProperty(Song)
    user = db.StringProperty()
    
    cover_url = db.StringProperty()
    songtaste_id = db.IntegerProperty()
    
    #the absolute url of the music file
    url = db.StringProperty()
    created_at = db.DateTimeProperty(auto_now_add = True)
    updated_at = db.DateTimeProperty(auto_now = True)

class SongInfo(db.Model):
    song = db.ReferenceProperty(Song)
    user = db.StringProperty()
    
    tag = db.StringProperty()
    comment = db.TextProperty()
    created_at = db.DateTimeProperty(auto_now_add = True)
    updated_at = db.DateTimeProperty(auto_now = True)

class SongList(db.Model):
    user = db.StringProperty()
    
    title = db.StringProperty()
    description = db.TextProperty()
    created_at = db.DateTimeProperty(auto_now_add = True)
    updated_at = db.DateTimeProperty(auto_now = True)

class SongListItem(db.Model):
    songlist = db.ReferenceProperty(SongList)
    song = db.ReferenceProperty(Song)
    order = db.IntegerProperty()
    created_at = db.DateTimeProperty(auto_now_add = True)
    updated_at = db.DateTimeProperty(auto_now = True)

class UserSong(db.Model):
    user = db.StringProperty()
    song = db.ReferenceProperty(Song)
    
    created_at = db.DateTimeProperty(auto_now_add = True)
    updated_at = db.DateTimeProperty(auto_now = True)

class SongTasteSong(db.Model):
    user = db.StringProperty()
    songtaste_id = db.IntegerProperty()
    
    title = db.StringProperty()
    artist = db.StringProperty()
    
    cover_url = db.StringProperty()
    
    #the absolute url of the music file
    url = db.StringProperty()
    created_at = db.DateTimeProperty(auto_now_add = True)
    updated_at = db.DateTimeProperty(auto_now = True)